#include "CustomButton.h"

#include <QPainter>
#include <QPixmap>

CustomButton::CustomButton(QString iconPath, QWidget *parent):QPushButton(parent)
{
    m_IconPath= iconPath;
    this->setStyleSheet("QPushButton { background-color: transparent; border: none; }QPushButton:hover{background-color:#b0afaf;}");
}

void CustomButton::paintEvent(QPaintEvent *event)
{
    QPushButton::paintEvent(event); // 保留按钮的样式表渲染
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    QPixmap pixmap(m_IconPath);

    painter.drawPixmap(2,2,width()-4,height()-4,pixmap);
}
